package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import po.User;
import service.UserService;

import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * Created by apple on 2017/10/20.
 */

@Controller
public class SignupController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/signup.do", produces="text/html;charset=UTF-8")
    @ResponseBody
    public String signup(User user) {

        if (userService.signupCheck(user.getUsername())) {
            userService.signupUser(user);
            return "注册成功";
        } else
            return "该用户已存在";
    }


}
